<!--title-->
<div class="mnav1">
    <div class="m_nav">
        <div class="nav_left">
            <em class="home_icon"><?=$this->sys_name?></em><span>&nbsp;&gt;&nbsp;</span><font><?=$this->title?></font>
        </div>
    </div>
</div>

<div class="content-table2">
    <div class="content-table-title"><?=$this->title?></div>
    <div class="form-edit-task">

        <form action="/others/admin-add-submit" method="post" name="form1" onsubmit="submitform(this);return false;">
            <table border="0" width="100%">
                <tr>
                    <td align="right">角色：</td>
                    <td align="left"><select name="positionId" id="positionId">
                            <option value="47">销售</option>
                            <option value="44">财务</option>
                            <option value="49">执行主管</option>
                        </select><font color="red"> *</font>
                    </td>
                </tr>
                <tr>
                    <td align="right" width="30%">登录名：</td>
                    <td align="left">&nbsp;<input type="text" placeholder="登录名" name="username" id="username" autocomplete="off"><font color="red"> *</font></td>
                </tr>
                <tr>
                    <td align="right" width="30%">登录密码：</td>
                    <td align="left">&nbsp;<input type="text" placeholder="登录密码" name="pwd" id="pwd" autocomplete="off"><font color="red"> *</font></td>
                </tr>
                <tr>
                    <td align="right" width="30%">姓名：</td>
                    <td align="left">&nbsp;<input type="text" placeholder="姓名" name="realName" id="realName" autocomplete="off"></td>
                </tr>
                <tr>
                    <td align="right" width="30%">邮箱：</td>
                    <td align="left">&nbsp;<input type="text" placeholder="邮箱" name="email" id="email" style="width: 300px" autocomplete="off"></td>
                </tr>
                <tr>
                    <td align="right">状态：</td>
                    <td align="left"><select name="status" id="status">
                            <option value="1" selected="selected">正常</option>
                            <option value="0">冻结</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="center"><input type="button" class="buttonlong" value="提交" onclick="submitform();return false;" /></td>
                </tr>
            </table>
            <br /><br />
        </form>
    </div>
    <br/><br/>
</div>


<script>
function submitform() 
{
	if( document.form1.username.value.length == 0 )
	{
		alert("登录名不能为空。");
		return false;
	}else if( document.form1.pwd.value.length == 0 )
	{
		alert("登录密码不能为空。");
		return false;
	}
	
	var username = document.getElementById('username').value;
	
	$.ajax({
	    type: "post",
	  	url : "/ajax/username-check",
	  	dataType:'json',
	  	data: {'username':username, 'exclude_id':0},
	  	success: function(json){
		    if(json.result == 1)
		    {
				form1.submit();
			}else{
	 	    	alert(json.reason);
				return false;
			}
	    }
	});
}
</script>